from flask_jwt_extended import get_jwt_identity


def get_admin_id():
    """获取管理员ID
    
    从JWT令牌中获取管理员ID，兼容字符串ID和字典格式的身份信息
    """
    current_user = get_jwt_identity()

    # 处理字符串ID
    if isinstance(current_user, str):
        return int(current_user)

    # 处理字典格式
    elif isinstance(current_user, dict) and 'id' in current_user:
        return current_user.get('id')

    # 处理整数
    elif isinstance(current_user, int):
        return current_user

    # 默认返回None
    return None
